import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

//export 暴露出方法供组件使用
//定义仓库 
//defineStore(仓库的唯一标识,()=>{...})
export const useDetailStore = defineStore('detail', () => {
    //声明数据
    const detailId = ref(null)
    //声明操作数据的方法action
    const setDetailId = (id) => {
        detailId.value = id
    }
    const getDetailId = computed(() => detailId.value)
    const reset = () => {
        detailId.value = null
    }
    const detailIsEmpty = computed(() => {
        return detailId.value === null||detailId.value === ''||detailId.value === undefined||detailId.value === 'undefined'||detailId.value === 'null'||detailId.value === 'NULL'||detailId.value === 'Null'||detailId.value === 'NULL'
    })
    //返回数据
    return { detailId , setDetailId, getDetailId , reset, detailIsEmpty }
}, {
    persist: true//配置持久化
})
